import request from '@/config/axios'

// AI 知识库文档 VO
export interface KnowledgeDocumentVO {
  id: number // 编号
  knowledgeId: number // 知识库编号
  name: string // 文档名称
  url: string // 文件 URL
  segmentMaxTokens: number // 分片最大 Token 数
  status: number // 状态
}

export interface KnowledgeDocumentListVO {
  knowledgeId: number // 知识库编号
  segmentMaxTokens: number // 分片最大 Token 数
  list: Document[] // 文档列表
}

export interface Document {
  name: string
  url: string
}

// AI 知识库文档 API
export const KnowledgeDocumentApi = {
  // 获取AI 知识库文档分页
  getKnowledgeDocumentPage: async (params: PageParam) => {
    return await request.get({ url: `/ai/knowledge/document/page`, params })
  },

  // 获取AI 知识库文档详情
  getKnowledgeDocument: async (id: number) => {
    return await request.get({ url: `/ai/knowledge/document/get`, params: { id } })
  },

  // 新增AI 知识库文档
  createKnowledgeDocument: async (data: KnowledgeDocumentVO) => {
    return await request.post({ url: `/ai/knowledge/document/create`, data })
  },

  // 新增AI 知识库文档
  createKnowledgeDocumentList: async (data: KnowledgeDocumentListVO) => {
    return await request.post({ url: `/ai/knowledge/document/create-list`, data })
  },

  // 修改AI 知识库文档
  updateKnowledgeDocument: async (data: Partial<KnowledgeDocumentVO>) => {
    return await request.post({ url: `/ai/knowledge/document/update`, data })
  },

  // 删除AI 知识库文档
  deleteKnowledgeDocument: async (id: number) => {
    return await request.delete({ url: `/ai/knowledge/document/delete`, params: { id } })
  },

  // 修改AI 知识库文档状态
  updateKnowledgeDocumentStatus: async (id: number, status: number) => {
    return await request.post({ url: `/ai/knowledge/document/update-status`, data: { id, status } })
  }
}
